#include <bits/stdc++.h>
#define gc getchar
#define pc putchar
#define pt printf
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rof(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
const int Mxn=1e5+5,P=1e9+7;
int N,T,F1[Mxn],F0[Mxn];
string S;
int _() {
	int x=0,f=0;char ch=gc();
	while(ch<'0'||ch>'9') f|=(ch=='-'),ch=gc();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=gc();
	return f?-x:x;
}
void __(int x) {
	int stk[30],tp=0;
	if(x<0) x=-x,pc('-');
	do stk[++tp]=x%10,x/=10;while(x);
	while(tp) pc(stk[tp--]^48);
}
int Add(int x,int y) {return x+y<P?x+y:x+y-P;}
signed main() {
	freopen("brotherhood.in","r",stdin);
	freopen("brotherhood.out","w",stdout);
	N=_(),T=_();
	F1[1]=0,F0[1]=1,F1[2]=1,F0[2]=1;
	For(i,3,N) {
		F1[i]=Add(F1[i-1],F1[i-2]);
		F0[i]=Add(F0[i-1],F0[i-2]);
	}
	while(T--) {
		cin>>S;
		if(S=="1") __(F1[N]),pc('\n');
		else if(S=="0") __(F0[N]),pc('\n');
	}
	return 0;
}
